window.onload = function () {
    init();
}

function init() {
    axios.get("/user/findById").then(resp => {
        let info = resp.data;
        $("head").src = "/img/" + info.head;
        $("name").innerHTML = info.name;
        $("email").innerHTML = info.email;
    })
    axios.get("/channel/findAll").then(resp => {
        let info = resp.data;
        let str = "";
        info.forEach(n => {
            str += `<tr><th><a href="javascript:selectChannel(${n.id})">${n.name}</a></th><th>${n.description}</th>
                    <th>${n.themeNum}</th></tr>`;
        })
        $("data").innerHTML = str;
    })
}

function selectChannel(id) {
    axios.get("/channel/selectChannel", {
        params: {
            channelId: id
        }
    }).then(resp => {
        if (resp.data == "ok") {
            location.href = "/forum/theme.html";
        }
    })
}